
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;


public class Menu extends javax.swing.JFrame {

    public Menu() {
        initComponents();
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnImport = new javax.swing.JToggleButton();
        iPImages = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        btnLuu = new javax.swing.JToggleButton();
        btnXoay90Trai = new javax.swing.JToggleButton();
        btnXoay90Phai = new javax.swing.JToggleButton();
        btnMail = new javax.swing.JButton();
        btnIn = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        btnXoayDoc = new javax.swing.JButton();
        btnXoayNgang = new javax.swing.JButton();
        btnTrangDen = new javax.swing.JToggleButton();
        btnLamMoAnh = new javax.swing.JToggleButton();
        btnLamPhaiMau = new javax.swing.JToggleButton();
        btnNegativeFilter = new javax.swing.JToggleButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtSeach = new javax.swing.JTextField();
        btnOK = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        jMenu4 = new javax.swing.JMenu();
        jMenu5 = new javax.swing.JMenu();
        helpMenu = new javax.swing.JMenu();
        contentsMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        btnImport.setText("Import");
        btnImport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnImportActionPerformed(evt);
            }
        });

        iPImages.setMaximumSize(null);
        iPImages.setName(""); // NOI18N
        iPImages.setPreferredSize(new java.awt.Dimension(400, 400));
        iPImages.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                iPImagesMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout iPImagesLayout = new javax.swing.GroupLayout(iPImages);
        iPImages.setLayout(iPImagesLayout);
        iPImagesLayout.setHorizontalGroup(
            iPImagesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(iPImagesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(803, Short.MAX_VALUE))
        );
        iPImagesLayout.setVerticalGroup(
            iPImagesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(iPImagesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(428, Short.MAX_VALUE))
        );

        jPanel2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.lightGray, java.awt.Color.lightGray, java.awt.Color.lightGray, java.awt.Color.lightGray));
        jPanel2.setPreferredSize(new java.awt.Dimension(6, 127));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 121, Short.MAX_VALUE)
        );

        btnLuu.setText("Lưu");
        btnLuu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLuuActionPerformed(evt);
            }
        });

        btnXoay90Trai.setText("Xoay 90 Trái");
        btnXoay90Trai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnXoay90TraiActionPerformed(evt);
            }
        });

        btnXoay90Phai.setText("Xoay 90 Phải");
        btnXoay90Phai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnXoay90PhaiActionPerformed(evt);
            }
        });

        btnMail.setText("Gửi Mail");
        btnMail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMailActionPerformed(evt);
            }
        });

        btnIn.setText("In");
        btnIn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnInActionPerformed(evt);
            }
        });

        jPanel3.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.lightGray, java.awt.Color.lightGray, java.awt.Color.lightGray, java.awt.Color.lightGray));
        jPanel3.setPreferredSize(new java.awt.Dimension(236, 6));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 230, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        btnXoayDoc.setText("Xoay Dọc");
        btnXoayDoc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnXoayDocActionPerformed(evt);
            }
        });

        btnXoayNgang.setText("Xoay Ngang");
        btnXoayNgang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnXoayNgangActionPerformed(evt);
            }
        });

        btnTrangDen.setText("Chuyển Màu");
        btnTrangDen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTrangDenActionPerformed(evt);
            }
        });

        btnLamMoAnh.setText("Làm Mờ Ảnh");
        btnLamMoAnh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLamMoAnhActionPerformed(evt);
            }
        });

        btnLamPhaiMau.setText("Làm Phai Màu");
        btnLamPhaiMau.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLamPhaiMauActionPerformed(evt);
            }
        });

        btnNegativeFilter.setText("Trắng Đen");
        btnNegativeFilter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNegativeFilterActionPerformed(evt);
            }
        });

        jLabel3.setText("Seach : ");

        btnOK.setText("OK");
        btnOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOKActionPerformed(evt);
            }
        });

        fileMenu.setMnemonic('f');
        fileMenu.setText("File");

        openMenuItem.setMnemonic('o');
        openMenuItem.setText("Open");
        openMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(openMenuItem);

        saveMenuItem.setMnemonic('s');
        saveMenuItem.setText("Save");
        fileMenu.add(saveMenuItem);

        saveAsMenuItem.setMnemonic('a');
        saveAsMenuItem.setText("Save As ...");
        saveAsMenuItem.setDisplayedMnemonicIndex(5);
        fileMenu.add(saveAsMenuItem);

        exitMenuItem.setMnemonic('x');
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setMnemonic('e');
        editMenu.setText("Edit");

        cutMenuItem.setMnemonic('t');
        cutMenuItem.setText("Cut");
        cutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cutMenuItemActionPerformed(evt);
            }
        });
        editMenu.add(cutMenuItem);

        copyMenuItem.setMnemonic('y');
        copyMenuItem.setText("Copy");
        copyMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                copyMenuItemActionPerformed(evt);
            }
        });
        editMenu.add(copyMenuItem);

        pasteMenuItem.setMnemonic('p');
        pasteMenuItem.setText("Paste");
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setMnemonic('d');
        deleteMenuItem.setText("Delete");
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        jMenu1.setText("View");
        menuBar.add(jMenu1);

        jMenu2.setText("Folder");
        menuBar.add(jMenu2);

        jMenu3.setText("Picture");
        menuBar.add(jMenu3);

        jMenu4.setText("Create");
        menuBar.add(jMenu4);

        jMenu5.setText("Tools");
        menuBar.add(jMenu5);

        helpMenu.setMnemonic('h');
        helpMenu.setText("Help");

        contentsMenuItem.setMnemonic('c');
        contentsMenuItem.setText("Contents");
        helpMenu.add(contentsMenuItem);

        aboutMenuItem.setMnemonic('a');
        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(49, 49, 49)
                        .addComponent(btnImport, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(btnXoayDoc)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnXoayNgang)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnTrangDen, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(btnLamMoAnh, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnLamPhaiMau, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(36, 36, 36)
                                .addComponent(btnNegativeFilter)
                                .addGap(299, 299, 299))
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 971, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtSeach, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnOK)
                        .addGap(21, 21, 21))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(iPImages, javax.swing.GroupLayout.PREFERRED_SIZE, 813, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(btnXoay90Phai)
                            .addComponent(btnXoay90Trai)
                            .addComponent(btnMail, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnIn, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnLuu, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnImport, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(txtSeach, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnOK))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(17, 17, 17)
                                .addComponent(btnXoay90Trai)
                                .addGap(39, 39, 39)
                                .addComponent(btnXoay90Phai)
                                .addGap(29, 29, 29)
                                .addComponent(btnMail)
                                .addGap(41, 41, 41)
                                .addComponent(btnIn)
                                .addGap(40, 40, 40)
                                .addComponent(btnLuu))
                            .addComponent(iPImages, javax.swing.GroupLayout.PREFERRED_SIZE, 439, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btnXoayDoc)
                                .addComponent(btnXoayNgang)
                                .addComponent(btnTrangDen)
                                .addComponent(btnLamMoAnh)
                                .addComponent(btnLamPhaiMau))
                            .addComponent(btnNegativeFilter))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 37, Short.MAX_VALUE))
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE))
                .addGap(23, 23, 23))
        );

        iPImages.getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents
    private String currentPath = "C:/Documents and Settings/All Users/Documents/" +
            "My Pictures/Sample Pictures";
    Image img;
    BufferedImage VungDem; 
    
    
    
    static final File dir = new File("PATH_TO_YOUR_DIRECTORY");

    // array of supported extensions (use a List if you prefer)
    static final String[] EXTENSIONS = new String[]{
        "gif", "png", "bmp" // and other formats you need
    };
    // filter to identify images based on their extensions
    static final FilenameFilter IMAGE_FILTER = new FilenameFilter() {

        @Override
        public boolean accept(final File dir, final String name) {
            for (final String ext : EXTENSIONS) {
                if (name.endsWith("." + ext)) {
                    return (true);
                }
            }
            return (false);
        }
    };

    
    
    
    
    
    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed
public  BufferedImage DenVungDem(Image im) {
     BufferedImage VungDem = new BufferedImage
        (im.getWidth(null),im.getHeight(null),BufferedImage.TYPE_INT_RGB);
     Graphics bg = VungDem.getGraphics();
     bg.drawImage(im, 0, 0, null);
     bg.dispose();
     return VungDem;
             }
            void showImg()
            {
              ImageIcon icon=new ImageIcon(img);
              jLabel1.setIcon(icon);
              jLabel1.setText("");
            }
    
    private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed

        JFileChooser jfc = new JFileChooser(currentPath);
        jfc.setMultiSelectionEnabled(true);
        jfc.showOpenDialog(null);
        File f = jfc.getSelectedFile();
        if (f != null) {
            try {
                currentPath = f.getCanonicalPath();
                jLabel2.setText(currentPath);
            } 
            catch (IOException ex) {
                Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
          Toolkit tkt = Toolkit.getDefaultToolkit();
              img = tkt.getImage(currentPath);
              
              img = img.getScaledInstance(iPImages.getWidth(), iPImages.getHeight(), Image.SCALE_FAST);
             
              ImageIcon icon=new ImageIcon(img);
             // bi = (BufferedImage) img;
              jLabel1.setIcon(icon);
              jLabel1.setText("");
                  
                VungDem = DenVungDem(img);
    }//GEN-LAST:event_btnImportActionPerformed

    private void btnXoayDocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoayDocActionPerformed
        PixelAnh pi = new PixelAnh(VungDem);
        XoayDoc.Xoay(pi);
        img = (Image) pi.getImage();
        showImg();
       
    }//GEN-LAST:event_btnXoayDocActionPerformed

    private void btnXoayNgangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoayNgangActionPerformed
         PixelAnh pi = new PixelAnh(VungDem);
        XoayNgang.Xoay(pi);
        img = (Image) pi.getImage();
        showImg();
        
        // TODO add your handling code here:
    }//GEN-LAST:event_btnXoayNgangActionPerformed

    private void btnTrangDenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTrangDenActionPerformed
        PixelAnh pix = new PixelAnh(VungDem);
        HinhAnh.ChuyenMau(pix);
        img = (Image) pix.getImage();
        showImg();
        
        // TODO add your handling code here:
    }//GEN-LAST:event_btnTrangDenActionPerformed

    private void btnLamMoAnhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLamMoAnhActionPerformed
    PixelAnh pix = new PixelAnh(VungDem);
        HinhAnh.MoAnh(pix);
        img = (Image) pix.getImage();
        showImg();
        
        // TODO add your handling code here:
    }//GEN-LAST:event_btnLamMoAnhActionPerformed

    private void btnLamPhaiMauActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLamPhaiMauActionPerformed
        PixelAnh pix = new PixelAnh(VungDem);
        HinhAnh.PhaiMau(pix);
        img = (Image) pix.getImage();
        showImg();
        
       
    }//GEN-LAST:event_btnLamPhaiMauActionPerformed

    private void btnNegativeFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNegativeFilterActionPerformed
         PixelAnh pix = new PixelAnh(VungDem);
        HinhAnh.TrangDen(pix);
        img = (Image) pix.getImage();
        showImg();
        
        // TODO add your handling code here:
    }//GEN-LAST:event_btnNegativeFilterActionPerformed

    private void btnLuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLuuActionPerformed
        String fileName="SaveImage1.PNG";
        HinhAnh.SaveToFile(VungDem, fileName);
        

    }//GEN-LAST:event_btnLuuActionPerformed

    private void btnXoay90TraiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoay90TraiActionPerformed
         PixelAnh pi = new PixelAnh(VungDem);
        XoayTrai90.Xoay(pi);
        img = (Image) pi.getImage();
        showImg();            
        
        // TODO add your handling code here:
    }//GEN-LAST:event_btnXoay90TraiActionPerformed

    private void btnXoay90PhaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoay90PhaiActionPerformed
        PixelAnh pi = new PixelAnh(VungDem);
        XoayPhai90.Xoay(pi);
        img = (Image) pi.getImage();
        showImg();      
        
        // TODO add your handling code here:
    }//GEN-LAST:event_btnXoay90PhaiActionPerformed

    private void btnMailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMailActionPerformed
        FGuiMail sendMail=new FGuiMail();
        sendMail.setField(jLabel2.getText());
        sendMail.setVisible(true);
        
        // TODO add your handling code here:
    }//GEN-LAST:event_btnMailActionPerformed

    private void btnInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInActionPerformed
        String fileName=jLabel2.getText();
        In printImg= new In();
        try {
            printImg.PrintImg(fileName);
        } catch (Exception ex) {
            Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
        }
        

    }//GEN-LAST:event_btnInActionPerformed

    private void cutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cutMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cutMenuItemActionPerformed

    private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
        // TODO add your handling code here:
        if (dir.isDirectory()) { // make sure it's a directory
            for (final File f : dir.listFiles(IMAGE_FILTER)) {
                BufferedImage img = null;

                try {
                    img = ImageIO.read(f);

                    // you probably want something more involved here
                    // to display in your UI
                    System.out.println("image: " + f.getName());
                    System.out.println(" width : " + img.getWidth());
                    System.out.println(" height: " + img.getHeight());
                    System.out.println(" size  : " + f.length());
                } catch (final IOException e) {
                    // handle errors here
                }
            }
        }
        
    }//GEN-LAST:event_btnOKActionPerformed

    private void openMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMenuItemActionPerformed
        // TODO add your handling code here:
        JFileChooser jfc = new JFileChooser(currentPath);
        jfc.showOpenDialog(null);
        File f = jfc.getSelectedFile();
        if (f != null) {
            try {
                currentPath = f.getCanonicalPath();
                jLabel2.setText(currentPath);
            } 
            catch (IOException ex) {
                Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
          Toolkit tkt = Toolkit.getDefaultToolkit();
              img = tkt.getImage(currentPath);
              
              img = img.getScaledInstance(iPImages.getWidth(), iPImages.getHeight(), Image.SCALE_FAST);
              
              ImageIcon icon=new ImageIcon(img);
             // bi = (BufferedImage) img;
              jLabel1.setIcon(icon);
              jLabel1.setText("");
                  
                VungDem = DenVungDem(img);
    }//GEN-LAST:event_openMenuItemActionPerformed

    private void copyMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyMenuItemActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_copyMenuItemActionPerformed

    private void iPImagesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_iPImagesMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_iPImagesMouseClicked
 

    public static void main(String args[]) {
     
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                
                Menu mn=new Menu();
        mn.setVisible(true);
        mn.setExtendedState(JFrame.MAXIMIZED_BOTH);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JToggleButton btnImport;
    private javax.swing.JButton btnIn;
    private javax.swing.JToggleButton btnLamMoAnh;
    private javax.swing.JToggleButton btnLamPhaiMau;
    private javax.swing.JToggleButton btnLuu;
    private javax.swing.JButton btnMail;
    private javax.swing.JToggleButton btnNegativeFilter;
    private javax.swing.JButton btnOK;
    private javax.swing.JToggleButton btnTrangDen;
    private javax.swing.JToggleButton btnXoay90Phai;
    private javax.swing.JToggleButton btnXoay90Trai;
    private javax.swing.JButton btnXoayDoc;
    private javax.swing.JButton btnXoayNgang;
    private javax.swing.JMenuItem contentsMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JPanel iPImages;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    private javax.swing.JTextField txtSeach;
    // End of variables declaration//GEN-END:variables
}
